<template>
  <view>
		<view class="tui-actionsheet"  :class="[show ? 'tui-actionsheet-show' : '']">
			<view class="regional-selection">
				<view class="specs">
				    <view class="specs-top">
				        <view style="font-size: 35rpx;font-weight: bold">分享给</view>  
						<!-- <view class="flex cancel-button">
							<u-icon name="close-circle" color="#999999" size="22" @click="handleClickMask()"></u-icon>					
						</view>   -->
				    </view>									
					<view class=" flex flex-wrap" >
						<block>
							<button class="classify-cell-recom bg-white" open-type="share" >
								<image class="share-img" src="../../static/resource/share_wx.png"></image>
								<text class="mt-10">微信好友</text>
							</button>
							<!-- <button class="classify-cell-recom bg-white" open-type="share">
								<image  class="share-img" src="../../static/resource/share_pyq.png"></image>
								<text class="mt-10">微信朋友圈</text>
							</button> -->
							<view class="classify-cell-recom bg-white" @click="shareload()">
								<image class="share-img" src="../../static/resource/share_img.png"></image>
								<text class="mt-10">保存分享图</text>
							</view>
						</block>
					</view>				    				    
				    <view class="ml-10 mr-15 border-t justify-center align-center text-center mt-20 pb-20" @click="handleClickMask()">
				    	<text class="cancels pt-15">取消</text>
				    </view>
				</view>			
			</view>
		</view>
		<!-- 遮罩层 -->
		<view  class="tui-actionsheet-mask"  :class="[show ? 'tui-mask-show' : '']"	  @tap="handleClickMask"></view>
  </view>
</template>
 
<script>
export default {
  // name: "tuiActionsheet",
  props: {
    //点击遮罩 是否可关闭
    maskClosable: {
      type: Boolean,
      default: true,
    },
    //显示操作菜单
    show: {
        type: Boolean,
        default: false,
       },
    },
	data(){
		return{
			shopInfo:{},
			goods_send:{}
		}
	},
	created() {
		this.shopInfo = uni.getStorageSync('shopInfo')
	},
    methods:  {
		handleClickMask() {
			 this.$emit("accessoryCancel",{type:1});
		},	
		//下载小程序分享码
		shareload(){
			let obj={
				token:uni.getStorageSync('userInfo').token,
			}
			uni.showLoading({
				title: '加载中'
			});
			this.$http.shopPoster(obj).then(res=>{
				if(res.resCode=='9999'){
					uni.downloadFile({
						url:  res.data.url,//必须是接口返回的路径，才可以保存到手机相册
						success(res) {
							console.log(res,'res下载返回图片路径');
							uni.hideLoading();
							// 图片保存到本地
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success(data) {
									uni.showToast({
										title: '保存成功',
										icon: 'success',
										duration: 2000
									});
								},
								fail(err) {
									console.log(err.errMsg);
									if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
										uni.showToast({
											title: '请允许访问相册后重试',
											icon: 'none',
											duration: 1000
										});
										setTimeout(() => {
											uni.openSetting();
										}, 1000);
									}
								},
								complete(res) {
									console.log('complete');
								}
							});
						}
					})
				}
			})
		}
    },
};
</script>
 
<style scoped lang="less">
	.cancels{
		display: flex;
		justify-content: center;
		padding-top: 15rpx;
		margin-top: 15rpx;
		font-weight: 400;
		font-size: 37rpx;
		color: #518FA0;
		line-height: 35rpx
	}
	.share-img{
		width: 99.39rpx;
		height: 99.39rpx;
	}
	.tag{
		display: flex;
		justify-content: center;
		align-items: center;
		text-align: center;
		font-size: 28rpx;
		font-weight: 400;
		color: #011F37;
		border-radius: 4px;
		background:rgba(15,21,30,0.05);
		padding: 26rpx;
	 
	}
	.classify-cell-recom{
	  display: flex;
	  flex-direction: column;
	  justify-content: center;
	  align-items: center;
	  text-align: center;
	  width: 28%;
	  margin: 20rpx 10rpx 0rpx 20rpx;
	  border-radius: 10rpx;  
	  font-size: 25rpx;
	  color: #4D4D4D;
	}
	
	.cancel-button{
		position: absolute;
		margin-top: 10rpx;
		right: 20rpx;
	}
	
.tui-actionsheet {
  width: 100%;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99999;
  visibility: hidden;
  transform: translate3d(0, 100%, 0);
  transform-origin: center;
  transition: all 0.3s ease-in-out;
  // background: #eaeaec;
  min-height: 100rpx;

}
 
.tui-actionsheet-show {
  transform: translate3d(0, 0, 0);
  visibility: visible;
}
.regional-selection {
    // text-align: center;
  // height: 391rpx;
  padding-bottom: 28rpx;
  background: #fff;
  border-radius: 20rpx 20rpx 0rpx 0rpx;
}
.tui-actionsheet-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9996;
  transition: all 0.3s ease-in-out;
  opacity: 0;
  visibility: hidden;
  
}
 
.tui-mask-show {
  opacity: 1;
  visibility: visible;
}


/* component/specs/index.wxss */

.specs-top-desc{
  display: flex;
  flex-direction: column;
  font-size: 25rpx;
  margin-left: 35rpx;
  color: gray;
  margin-top: 15rpx;
  
}

.specs-top-title{
  display: flex;
  flex-direction: row;
  justify-content: left;
  font-size: 25rpx;
  margin-left: 35rpx;  
  margin-top: 25rpx;
  
}

.localtion{
  display: flex;
  flex-direction: row;
  color: gray;
}

.specs-top{
  display: flex;
  flex-direction: row;
  font-size: 23rpx;
  justify-content: center;
  align-items: center;
  padding-bottom: 10rpx;
  // border-bottom: 1rpx solid rgb(240, 235, 235);
  padding-top: 20rpx;
 

 
}


</style>